<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <script src="../layui/layui.js"></script>
</head>
<body>
<div class="layui-btn-group demoTable">
    <button class="layui-btn" data-type="getCheckData">获取选中行数据</button>
</div>
<table id="myTable"></table>
<script>
    layui.use(['laydate', 'laypage', 'layer', 'table'], function(){
        var table = layui.table;
        table.render({
            elem: '#myTable'
            ,url:'/spring-web/getUsers'
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,page: true
            ,id:"tableId"  //操作使用
            ,cols: [[
                {type:'checkbox'},
                {field:'id', width:80, title: 'ID', sort: true}
                ,{field:'username', width:80, title: '用户名'}
                ,{field:'sex', width:80, title: '性别', sort: true}
                ,{field:'city', width:80, title: '城市'}
                ,{field:'sign', title: '签名', width: '30%', minWidth: 100} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                ,{field:'experience', title: '积分', sort: true}
                ,{field:'score', title: '评分', sort: true}
                ,{field:'classify', title: '职业'}
                ,{field:'wealth', width:137, title: '财富', sort: true}
            ]]
        });
        var $ = layui.$;
        $("button[data-type='getCheckData']").click(function(){
            var checkStatus = table.checkStatus('tableId')
                ,data = checkStatus.data;
            layer.alert(JSON.stringify(data));
        });
    });
</script>
</body>
</html>